/**
 * Copyright 2009-2010 - YangJiandong(chunquedong)
 * 
 * This file is part of ChunMap project
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
 * 你可以自由复制、传播本项目的下载包文件，但必须保持其完整性。
 * 我们不用对使用中的风险及由此造成的损失承担任何责任。
 * 详细情况请见《ChunMap许可协议》。

 * 想了解更多有关ChunMap的信息，请访问http://code.google.com/p/chunmap/
 */
package chunmap.view.render;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;

/**
 * @author chunquedong
 * 
 */
public class Painter {

	private Image image;
	private Graphics2D g;
	private int width;
	private int height;

	public Painter(int width, int height) {
		reset(width, height);
	}

	public void reset(int width, int height) {
		this.width = width;
		this.height = height;
		image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		g = (Graphics2D) image.getGraphics();
		setBackground(Color.white);
	}

	public void setBackground(Color c) {
		g.setBackground(c);
	}

	public void clear() {
		g.clearRect(0, 0, width, height);
	}

	public Image getData() {
		image.flush();
		return image;
	}
	
	public Graphics2D getGraphics(){
		return g;
	}
}
